#include"StdAfx.h"

pgMat44::pgMat44()
{
	val[0][0] = 0.0f;
	val[0][1] = 0.0f;
	val[0][2] = 0.0f;
	val[0][3] = 0.0f;

	val[1][0] = 0.0f;
	val[1][1] = 0.0f;
	val[1][2] = 0.0f;
	val[1][3] = 0.0f;

	val[2][0] = 0.0f;
	val[2][1] = 0.0f;
	val[2][2] = 0.0f;
	val[2][3] = 0.0f;

	val[3][0] = 0.0f;
	val[3][1] = 0.0f;
	val[3][2] = 0.0f;
	val[3][3] = 0.0f;
}

pgMat44::pgMat44(float f11, float f12, float f13, float f14,
		float f21, float f22, float f23, float f24,
		float f31, float f32, float f33, float f34,
		float f41, float f42, float f43, float f44)
{
	val[0][0] = f11;
	val[0][1] = f12;
	val[0][2] = f13;
	val[0][3] = f14;

	val[1][0] = f21;
	val[1][1] = f22;
	val[1][2] = f23;
	val[1][3] = f24;

	val[2][0] = f31;
	val[2][1] = f32;
	val[2][2] = f33;
	val[2][3] = f34;

	val[3][0] = f41;
	val[3][1] = f42;
	val[3][2] = f43;
	val[3][3] = f44;
}

pgMat44::pgMat44(const XMMATRIX &m)
{
	val[0][0] = m._11;
	val[0][1] = m._12;
	val[0][2] = m._13;
	val[0][3] = m._14;

	val[1][0] = m._21;
	val[1][1] = m._22;
	val[1][2] = m._23;
	val[1][3] = m._24;

	val[2][0] = m._31;
	val[2][1] = m._32;
	val[2][2] = m._33;
	val[2][3] = m._34;

	val[3][0] = m._41;
	val[3][1] = m._42;
	val[3][2] = m._43;
	val[3][3] = m._44;
}

pgVec3 pgMat44::GetRightAxis()
{
	return pgVec3(val[0][0], val[0][1], val[0][2]);
}

pgVec3 pgMat44::GetUpAxis()
{
	return pgVec3(val[1][0], val[1][1], val[1][2]);
}

pgVec3 pgMat44::GetFwdAxis()
{
	return pgVec3(val[2][0], val[2][1], val[2][2]);
}

pgVec3 pgMat44::GetTranslation()
{
	return pgVec3(val[3][0], val[3][1], val[3][2]);
}

pgMat44 pgMat44::operator * (const pgMat44 &m)
{
	pgMat44 newMat;

	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 4; ++j)
		{
			for (int k = 0, l = 0; k < 4; ++k,  ++l)
			{
				newMat.val[i][j] += val[i][k] * m.val[l][j];
			}
		}
	}

	return newMat;
}
	

